#include<iostream>
#include<string>
using namespace std;
int x, n;
string s;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> x;
		cin >> s;
		int ans = 0;
		bool flag = 0;
		for (int i = 0; i < s.size(); i++) {
			int k = s[i] - '0';
			if (k < x) {
				ans = i;
				flag = 1;
				break;
			}
		}
		if (!flag) {
			cout << s;
			cout << x << endl;
		}
		else {
			for (int i = 0; i < ans; i++) {
				cout << s[i];
			}
			cout << x;
			for (int i = ans; i < s.size(); i++) {
				cout << s[i];
			}
			cout << endl;
		}
	}
	return 0;
}